<?php
/**
 *
 * Customer Seach Result Grid
 *
 */

use Nawa\MedicalStudy\Role;
use Fox\Generator;
use Fox\Common\Customer\Type;
use Fox\Html\AnchorObject;

global $typeLabel;
$typeLabel = array();
$finder = new Type();
$types = $finder->find(new Fox\Dao\SqlFragment("language = ?",array(Xview::instance()->language())));
foreach($types as $type)
{
	$typeLabel[$type->type] = $type->label();
}
$grid = new Fox\Grid("gResult");
$grid->fieldcat(array("name1","name2","email1",array("role","function"),"applicationaccess","udate"));
$grid->fieldcat()->switchToObjectMode();
$grid->fieldcat()->field("function")->setGenerator(Generator::useFunction(function ($data){
	return Role::labelize($data->function);
}));

$grid->setFieldAttr(array("name1","name2","email1"),"setAnchor",
new AnchorObject("?mod=customers&act=update",array(
					'customerid' => Fox\Generator::useAttribute())
));
	
return $grid;